<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Order detail</title>

    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <!-- jquery-validator -->
    <script src="https://cdn.bootcss.com/jquery-validate/1.19.1/jquery.validate.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-validate/1.19.1/localization/messages_zh.js"></script>
    <!--    layer-->
    <script src="https://cdn.bootcss.com/layer/1.8.5/layer.min.js"></script>
    <!-- md5.js -->
    <!--    <script src="https://github.com/emn178/js-md5/blob/master/build/md5.min.js"></script>-->
    <script type="text/javascript" src="/js/md5.min.js"></script>
    <!-- common.js -->
    <script type="text/javascript" src="/js/common.js"></script>
</head>
<body>

<div class="panel panel-default">
    <div class="panel-heading">秒杀订单详情</div>
    <div class="panel-body">
        <table class="table" id="goodslist">
            <tr>
                <td>商品名称</td>
                <td id="goodsName" colspan="3"></td>
            </tr>
            <tr>
                <td>商品图片</td>
                <td colspan="2"><img id="goodsImg" width="200" height="200"/></td>
            </tr>
            <tr>
                <td>订单价格</td>
                <td colspan="2" id="goodsPrice"></td>
            </tr>
            <tr>
                <td>下单时间</td>
                <td id="createDate" colspan="2"></td>
            </tr>
            <tr>
                <td>订单状态</td>
                <td id="orderStatus"></td>
                <td>
                    <button class="btn btn-primary btn-block" type="button" id="payButton">立即支付</button>
                </td>
            </tr>
            <tr>
                <td>收货人</td>
                <td colspan="2">XXX 18812341234</td>
            </tr>
            <tr>
                <td>收货地址</td>
                <td colspan="2">北京市昌平区回龙观龙博一区</td>
            </tr>
        </table>
    </div>
</div>

</body>
<script>

    $(function () {
        layer.closeAll();
        getDetail();
    });

    function render(detail) {
        var goods = detail.goodsVo;
        var order = detail.order;

        $("#goodsName").text(goods.goodsName);
        $("#goodsImg").attr("src", goods.goodsImg);
        $("#goodsId").val(goods.id);//[JavaScript]不支持全局变量，但有时我们必须用全局变量，我们就可以把值先存在隐藏域里，它的值就不会丢失了
        $("#goodsPrice").text(goods.goodsPrice);
        $("#spikePrice").text(goods.spikePrice);
        $("#createDate").text(new Date(order.createDate).format("yyyy-MM-dd hh:mm:ss"));
        var status = "";
        if (order.status == 0) {
            status = "未支付"
        } else if (order.status == 1) {
            status = "待发货";
        }
        $("#orderStatus").text(status);
    }

    function getDetail() {
        var orderId = g_getQueryString("orderId");
        $.get({
            url: "/order/detail/" + orderId,
            success: function (data) {//OrderDetailVo
                if (0 === data.code) {
                    render(data.data);
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function () {
                layer.msg("client request error");
            }
        });
    }
</script>


</html>